

package com.xgit.iov.common.core.model;

import com.xgit.iov.common.core.entity.SysMenu;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @author lengleng
 * @date 2017年11月9日23:33:27
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MenuTree extends TreeNode implements Serializable {
	/**
	 * 菜单图标
	 */
	private String icon;
	/**
	 * 菜单名称
	 */
	private String name;
	private boolean spread = false;
	/**
	 * 前端路由标识路径
	 */
	private String path;
	/**
	 * 路由缓冲
	 */
	private String keepAlive;
	/**
	 * 权限编码
	 */
	private String permission;
	/**
	 * 菜单类型 （0菜单 1按钮）
	 */
	private String type;
	/**
	 * 菜单标签
	 */
	private String label;
	/**
	 * 排序值
	 */
	private Integer sort;

	public MenuTree() {
	}

	public MenuTree(Long id, String name, Long parentId) {
		this.id = id;
		this.parentId = parentId;
		this.name = name;
		this.label = name;
	}

	public MenuTree(Long id, String name, MenuTree parent) {
		this.id = id;
		this.parentId = parent.getId();
		this.name = name;
		this.label = name;
	}

	public MenuTree(SysMenu sysMenu) {
		this.id = sysMenu.getId();
		this.parentId = sysMenu.getParentId();
		this.icon = sysMenu.getIcon();
		this.name = sysMenu.getName();
		this.path = sysMenu.getPath();
		this.type = sysMenu.getType();
		this.permission = sysMenu.getPermission();
		this.label = sysMenu.getName();
		this.sort = sysMenu.getSort();
		this.keepAlive = sysMenu.getKeepAlive();
	}
}
